#include "GMKeyChangeSDL.h"
#include "Engine.h"     /* Different Per Project - Hack! */
#include "GameState.h"  /* Different Per Project - Hack! */

void GMKeyChangeSDL::SetKey(const SDL_KeyboardEvent& e )
{
    m_type = e.type;
    m_state = e.state;
    m_key = e.keysym.sym;
}
bool GMKeyChangeSDL::ReadFromSckMsg( Networking::SockMsg* sm )
{
    if(!sm->ReadInt(&m_type))
        return false;
    if(!sm->ReadInt(&m_state))
        return false;
    if(!sm->ReadInt(&m_key))
        return false;
    if(!sm->ReadInt(&m_clientID))
        return false;

    return true;
}
void GMKeyChangeSDL::WriteToSckMsg( Networking::SockMsg* sm )
{
    sm->WriteInt(m_type);
    sm->WriteInt(m_state);
    sm->WriteInt(m_key);
    sm->WriteInt(m_clientID);
}

bool GMKeyChangeSDL::Execute()
{
    Engine::Instance()->GetCurrentState()->NotifyKeyPressSDL(m_type, m_state, m_key, m_clientID);
    return true;
}